package cn.edu.scau.cmi.huxiantao.factory;

import java.net.URL;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.huxiantao.domain.Injury;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ListView;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

public class FXMLController implements Initializable{
	@FXML
	private ListView<String> listView;
	@FXML
	private ChoiceBox<String> choiceBox;
	@FXML
	private ImageView imageView;
	
	
	private ObservableList<String> list;
	
	@FXML
	private void onShowInsuInfo() {
		int index=choiceBox.getSelectionModel().getSelectedIndex();
		
		InsuranceFactory factory=null;
		switch(index) {
		case 0:
			factory=new BodyInjuryFactory();
			break;
		case 1:
			factory=new CarInjuryFactory();
			break;
		case 2:
			factory=new ManInjuryFactory();
			break;
		case 3:
			factory=new MultInjuryFactory();
			break;
		}
		
		Injury injury=factory.getInstance();
		String info=injury.getInfo();
		list.add(info);
	}
	
	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		choiceBox.setItems(FXCollections.observableArrayList("身体受伤","汽车损坏","人员伤亡","多种事故"));
		choiceBox.setValue("身体受伤");
		list=FXCollections.observableArrayList();
		listView.setItems(list);
		imageView.setImage(new Image("/cn/edu/scau/cmi/huxiantao/pic/pic.jpg"));
		
	}
}
